package com.wider.foundation;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * This class provides static methods for advanced String operations
 * @author William Choi <avextk@gmail.com>
 */
public class xString {
    public static String substring(String string, String pattern){
        return string.substring(string.indexOf(pattern));
    }

    public static String substring(String string, String pattern, int length){
        int i = string.indexOf(pattern);
        int j = i + length - 1;
        return string.substring(i, j);
    }

    public static String substring(String string, String start, String end){
        int i = string.indexOf(start);
        int j = string.indexOf(end) + end.length();
        return string.substring(i, j);

    }

    public static String substringAfter(String string, String pattern){
        return string.substring(string.indexOf(pattern) + pattern.length());
    }

    public static String substringAfter(String string, String pattern, int length){
        int i = string.indexOf(pattern) + pattern.length();
        int j = i + length - 1;
        return string.substring(i, j);
    }

    public static String substringBetween(String string, String start, String end){
        int i = string.indexOf(start) + start.length();
        int j = string.indexOf(end);
        return string.substring(i, j);
    }
}
